package repositories;

import java.util.Collection;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import domain.Comment;

@Repository
public interface CommentRepository extends JpaRepository<Comment, Integer> {
	@Query("select c from Comment c where c.availableItem.seller.id=?1")
	Collection<Comment> findCommentsBySeller(int sellerId);
	
	@Query("select c from Comment c where c.availableItem.id=?1")
	Collection<Comment> findCommentsByItemId(int availableItemId);
	
	@Query("select avg(c.rating) from Comment c where c.availableItem.seller.id=?1")
	Double findAverageRatingBySeller(int sellerId);

	

}
